<template>
  <div style="margin-top:30px">
    <el-form ref="form" :model="form" label-width="80px" :rules="rules">
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="入驻商" style="margin-right:15px" prop="shipmentCode">
              <el-input v-model="form.shipmentCode" placeholder="请输入入驻商" style="width:100%"/>
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="状态名称" style="margin-right:15px" prop="name">
             <!-- <el-select v-model="form.name" placeholder="请输入库存状态名称" clearable style="width:100%">
                <el-option value="0" label="合格"/>
                <el-option value="1" label="残损"/>
              </el-select>-->
              <el-input v-model="form.name" placeholder="请输入库存状态名称" style="width:100%"/>
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="是否可发货" style="margin-right:15px" prop="isConsignment">
              <el-select v-model="form.isConsignment" placeholder="请输入是否可发货" clearable style="width:100%">
                <el-option value="0" label="是"/>
                <el-option value="1" label="否"/>
              </el-select>

            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="备注" style="margin-right:15px">
              <el-input v-model="form.remarks" placeholder="请输入备注" style="width:100%"/>
            </el-form-item>
          </div>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="funcCancel">取 消</el-button>
      <el-button type="primary" @click="funcSubmit">确 定</el-button>
    </div>
  </div>
</template>
<script>
import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import request from '@/utils/request'
import { inventoryStatusAdd} from '@/api/basicInfo'

Vue.use(VXETable)
export default {
  data() {
    return {
      form: {
        name:'',               //库存状态 ,
        code:'',                      //数据标识 ,
        isConsignment:'',             //是否可发货
        remarks:'',                   //备注 ,
        shipmentCode:'',              //所属入驻商 ,
        status:'0',
        isDeleted:'0',
        deleted:'0',
      },
        rules: {
          name: [
            {required: true, message: '请输入库存状态', trigger: 'blur'},
          ],
          isConsignment: [
            {required: true, message: '请输入是否可发货', trigger: 'blur'},
          ],

          shipmentCode: [
            {required: true, message: '请选择所属入驻商', trigger: 'blur'},
          ],
        },
    }
  },
  created() {
  },
  methods: {
    // 重置
    reset(){
      this.$refs['form'].resetFields()
    },
    // 提交
    funcSubmit() {
      const data = this.form
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.isDisable = true
          inventoryStatusAdd(data).then(response => {
            this.$message({ message: response.msg, type: 'success' })
            this.$emit('fatherAddMethod')
            this.form = {}
          }).catch(() => this.isDisable = false)
        } else {
          return false
        }
      })

    },
    // 取消
    funcCancel() {
      this.$emit('fatherCancelMethod', 'add')
    }
  }
}
</script>
<style lang="scss" scoped >
  .dialog-footer {
    margin: 15px 0 15px 0;
    width: 175px;
    float: right;
  }
</style>
